package com.function;

import com.stream.Person;
import com.stream.User;

import java.util.Collections;
import java.util.List;
import java.util.function.Function;

/**
 * Description:
 *
 * @Create 2023/12/7 23:15
 * @Version 1.0
 */
public class Test {
    public static void main(String[] args) {
        User user = new User();
        //查询得到总页数
        int pages = 100;
//        findAndSaveData(pages, user, User::setAge, x -> findUsers((User) x), y -> savePerson((List<Person>) y));
    }

    public static <T, W> void findAndSaveData(int pages, W query, Function<Integer, Void> func1,
                                              Function<W, List<T>> func2, Function<List<T>, Integer> func3) {
        for (int i = 1; i <= pages; i++) {
            func1.apply(i);
            List<T> list = func2.apply(query);

            func3.apply(list);
        }
    }

    public static List<Person> findUsers(User user) {
        Person person = new Person();
        person.setName(user.getName());
        return Collections.singletonList(person);
    }

    public static int savePerson(List<Person> persons) {
        System.out.println("--------> save");
        return 1;
    }



}
